package wechat.rcv.cosuming;

import org.apache.log4j.Logger;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import wechat.rcv.cosuming.EventClickConsuming;
import wechat.rcv.cosuming.EventSubscribeConsuming;
import wechat.rcv.cosuming.EventUnSubscribeConsuming;
import wechat.rcv.cosuming.IMsgConsuming;
import wechat.rcv.cosuming.RequestObj;
import wechat.rcv.cosuming.TxtMsgConsuming;

@Component
@SuppressWarnings("all")
public class WXRequestTree {
  private static Logger logger = Logger.getLogger("WXRequestTree");
  
  private IMsgConsuming consumObj;
  
  private RequestObj ro;
  
  @Autowired
  private TxtMsgConsuming txtMsgConsuming;
  
  @Autowired
  private EventClickConsuming eventClickConsuming;
  
  @Autowired
  private EventUnSubscribeConsuming eventUnSubscribeConsuming;
  
  @Autowired
  private EventSubscribeConsuming eventSubscribeConsuming;
  
  public IMsgConsuming getHandler(final RequestObj r) {
    this.ro = r;
    String _msgType = this.ro.getMsgType();
    String _plus = ("EventAckConsuming ro.msgType = " + _msgType);
    WXRequestTree.logger.info(_plus);
    String _msgType_1 = this.ro.getMsgType();
    switch (_msgType_1) {
      case "event":
        String _event = this.ro.getEvent();
        switch (_event) {
          case "subscribe":
            final Procedure1<EventSubscribeConsuming> _function = new Procedure1<EventSubscribeConsuming>() {
              @Override
              public void apply(final EventSubscribeConsuming it) {
                it.setRequestObj(WXRequestTree.this.ro);
              }
            };
            return ObjectExtensions.<EventSubscribeConsuming>operator_doubleArrow(this.eventSubscribeConsuming, _function);
          case "unsubscribe":
            final Procedure1<EventUnSubscribeConsuming> _function_1 = new Procedure1<EventUnSubscribeConsuming>() {
              @Override
              public void apply(final EventUnSubscribeConsuming it) {
                it.setRequestObj(WXRequestTree.this.ro);
              }
            };
            return ObjectExtensions.<EventUnSubscribeConsuming>operator_doubleArrow(this.eventUnSubscribeConsuming, _function_1);
          case "click":
            String _event_1 = this.ro.getEvent();
            String _plus_1 = ("EventClickConsuming ro.event = " + _event_1);
            WXRequestTree.logger.info(_plus_1);
            EventClickConsuming _eventClickConsuming = new EventClickConsuming();
            final Procedure1<EventClickConsuming> _function_2 = new Procedure1<EventClickConsuming>() {
              @Override
              public void apply(final EventClickConsuming it) {
                it.setRequestObj(WXRequestTree.this.ro);
              }
            };
            return ObjectExtensions.<EventClickConsuming>operator_doubleArrow(_eventClickConsuming, _function_2);
        }
        break;
    }
    return null;
  }
}
